package steffens.java.gui.treeview.model;

import java.util.Arrays;


public class Test {

	public Test() {
		TreeList<String> strings = new TreeList<String>();
		strings.add("a");
		strings.add("b");
		strings.addChild("b", "b1");
		strings.addChild("b", "b2");
		strings.add("c");
		strings.addChild("c", "c1");
		strings.addChild("c", "c2");
		strings.getChildren(2).addChild("c2", "c2.1");
		strings.addChild(new int[]{2,1,0}, "TEST");
		strings.addChild(new int[]{2,1,0}, "TEST1");
		strings.addChild(new int[]{2,1,0}, "TEST2");
		strings.addChild(new int[]{2,1,0}, "TEST3");
		strings.addChild(new int[]{2,1,0,3}, "TEST3.0");
//		strings.add("1", 1);
//		strings.addAll(Arrays.asList("w","x","y","z"));
//		strings.addAllChildren("a", Arrays.asList("w","x","y","z"));
//		strings.addAll(Arrays.asList("?","!","<",">"),2);
		printTree(strings,0);
		strings.retainAll(Arrays.asList("b","b1","b2","TEST3.0","c2.1"));
		printTree(strings,0);
//		System.out.println(strings.getPath("bbbc"));
//		System.out.println(strings.getElement(new int[]{1,0,5,0}));
//		strings.remove("b");
//		
//		printTree(strings,0);
//		System.out.println(strings.indexOf("a"));
//		System.out.println(strings.indexOf("a", 4));
//
//
//		strings.clear();
		
		
//		printList(strings);
//		strings.remove("b");
//		printList(strings);
//		strings.remove("a");
//		printList(strings);
//		strings.remove("c");
//		printList(strings);
		
		
	}
	
	private void printTree(TreeList<String> strings, int depth){
		
		TreeIterator<String> iterator = strings.iterator();
		while(iterator.hasNext()){
			for(int i = 0 ; i < depth; i++)System.out.print("\t");
			String e = iterator.next();
			System.out.println(iterator.getIndex() +" "+e);
			if(iterator.hasChildren()){
				printTree(iterator.getChildren(), depth+1);
			}
		}
	}
	
	private void printList(TreeList<?> list) {
		System.out.println("_________________");
		for(Object obj: list){
			System.out.println(obj);
		}
	}
	
	public static void main(String[] args) {
		new Test();
	}
}
